function out=vocode(a,b,numBands,sampRate)
doplot=false;
if ~isvector(a) || ~isvector(b) || ~(length(a)==length(b)) || ~isinteger(numBands) || numBands<1 || numBands>sampRate/2
    if abs(length(a)-length(b))==1
        a=a(1:min(length(a),length(b)));
        b=b(1:min(length(a),length(b)));
    else
    size(a)
    size(b)
    numBands
    error('bad args')
    end
end

bands=linspace(0,sampRate/2,numBands+1);
bands=[bands(1:end-1);bands(2:end)];

out=zeros(numBands,length(a));
carrier=out;
envelope=out;
filts=out;

if doplot
    c=jet;
    c=c(round(linspace(1,size(c,1),numBands)),:);
end

for i=1:numBands
    filts(i,:)=bandPass(a,bands(2,i),bands(1,i),sampRate);
    envelope(i,:)=bandPass(abs(filts(i,:)),50,1,sampRate);
    envelope(i,envelope(i,:)<0)=0;
    
    j=ceil(rand*i);
    if j==0
        i
        %beep
        j=1;
    end
    carrier(i,:)=bandPass(b,bands(2,j),bands(1,j),sampRate);

    if doplot
        plot([[filts(i,:)]' [envelope(i,:)]' zeros(length(a),1)]+3.0*double(i),'Color',c(i,:));
        hold on
    end
end

out=envelope.*carrier;

out = sum(out);

out=2*((out-min(out))/range(out))-1;